import asyncio
import os
import time
from concurrent.futures import ThreadPoolExecutor

import requests


def get_status_code(url):
    response = requests.get(url)
    return response.status_code


start = time.time()
with ThreadPoolExecutor(max_workers=os.cpu_count() + 4) as pool:
    urls = ["http://www.baidu.com" for _ in range(100)]
    results = pool.map(get_status_code, urls)
    for result in results:
        print(result)
end = time.time()

print(f"总共花费时间：{end - start:.4f}s")
